<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/12
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>成果列表</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn {
        text-align: right;
    }
    .layui-form-item {
        margin-bottom: 5px;
    }
    .layui-input-inline{
        width: 300px !important;
    }
    .layui-icon-ok{
        margin-top: 6px;
    }
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
    .item img {
        height: 40px;
    }
</style>
<body>
<div>
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"><span style="font-size: 22px;display: inline-block;vertical-align: middle;">成果列表</span>
    </div>
    <hr class="layui-bg-blue">
    <div>
        <div class="btn">
            <div style="margin-left: 10px;float: left" class="layui-form">
                <input type="radio" checked name="status" value="" lay-filter="status" value="" title="全部">
                <input type="radio" name="status" value="1"  lay-filter="status" title="申报中">
                <input type="radio" name="status" value="2"  lay-filter="status" title="结束">
            </div>
            <div>
                <a href="/Recognize/getProjectTopic?ctreateType=4&userId=1&isExport=true" type="button" class="layui-btn immp layui-btn-sm " id="del" style="margin-right: 15px" >
                    <i class="layui-icon">&#xe601;</i>
                    导出
                </a>
            </div>
        </div>
    </div>
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>

</body>
</html>
<script>
    var ue;   //编辑器的返回值
    var table,form,laydate,upload,laydate;
    //关闭弹框刷新页面
    function closes(){
        layer.closeAll();
    }

    //判断类型是否存在
    function isRemarks( remarks , trType){
        for (var i = 0; i < remarks.length; i++) {
            if (remarks[i].trType == trType){
                return remarks[i];
            }
        }
        return '';
    }

    layui.use(['table', 'layer', 'form','laydate','upload'], function () {
        var table = layui.table
            , layer = layui.layer
            , form = layui.form
            , upload = layui.upload
            , laydate = layui.laydate
        $(document).ready(function(){
            form.render();
        });
        var tableInt = table.render({
            elem: '#test'
            ,url:'/Recognize/getProjectTopic'
            ,where:{
                ctreateType:4,
                userId:"成果列表",
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.object, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            , cols: [[
                {type: 'checkbox'},
                {field: 'planName', title: '任务名称', align: 'center',templet: function(d){
                        return d.rpmPlan.planName;
                    }}
                , {field: 'topicName', title: '成果名称', align: 'center'}
                , {field: 'topicTypeName', title: '成果类型', align: 'center'}
                , {field: 'userName', title: '申报人姓名', align: 'center'}
                , {field: 'deptName', title: '科室', align: 'center'}
                , {title: '申报状态', align: 'center',templet: function(d){
                        if(d.rpmPlan.state=='1'){
                            return '申报中'
                        }else if(d.rpmPlan.state=='2'){
                            return '申报结束'
                        }
                    }}
                , {title: '主任审核意见', align: 'center',templet: function(d){
                        var remark15 = isRemarks(d.remarks , '15');
                        if( remark15 != '' ){
                            return remark15['trRemark'];
                        }
                        return '';
                    }}
                , {field: 'type', title: '操作',templet: function(d){
                        var str =  '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="look">查看</a>\n';
                        if( ( d.rpmPlan.state == '1' ) && ( isRemarks(d.remarks , '15') == ''  || ( isRemarks(d.remarks , '15' ) !='' && isRemarks(d.remarks , '15' )['trStatus'] == '3') ) ){
                            str += '<a class="layui-btn layui-btn-xs" lay-event="edit" >编辑</a>\n';
                        }
                        str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>';
                        return str;
                    }}
            ]],
            page:true
        });

        //监听顶部单选按钮
        form.on('radio(status)', function(data){
            var value = data.value;
            table.reload('test', {
                where:{
                    state:value
                }
            });
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var layEvent = obj.event;
            var tr = obj.tr;
            var data = obj.data;

            if(layEvent === 'edit'){
                layer.open({
                    type: 2,
                    title:'编辑',
                    btn: ['保存', '保存并提交'],
                    area: ['70%', '85%'],
                    content: '/Results/declaration?planId='+data.planId+'&type='+1 +'&topicId=' + data.topicId,
                    yes:function (index, layero) {
                        var myIframe = window[layero.find('iframe')[0]['name']];
                        var fnc = myIframe.listSubmitEdit();
                        table.reload('test');
                    },
                    btn2:function (index, layero) {
                        var saveIframe = window[layero.find('iframe')[0]['name']];
                        var fnc = saveIframe.listSubmitsave();
                        table.reload('test');
                    }
                })
            }else if(layEvent === 'look'){
                layer.open({
                    type: 2,
                    title:'查看',
                    btn: ['返回'],
                    area: ['70%', '85%'],
                    content: '/Results/declaration?type=1&planId=' + data.planId + '&topicId=' + data.topicId+'&edit=0',
                    yes:function (index, layero) {
                        layer.close(index);
                    }
                })
            }else if(layEvent === 'del'){
                console.log(data)
                layer.confirm('确定删除行么', function(index){
                    $.get('/Recognize/delTopic',{topicId:data.topicId},function(res){
                        if (res.flag){
                            obj.del();
                        }
                    });
                    layer.close(index);
                });
            }
        });


    })



</script>
